package tomove;


import org.jbehave.core.annotations.AfterStory;
import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;
import org.junit.runner.RunWith;
import net.thucydides.junit.runners.ThucydidesRunner;

import com.aol.library.AolLibrary;
import com.selenium.library.Driver;

/* Author - Payal Garg
   StoryName - search_product.story
   Date created - 29-05-2013*/

@RunWith(ThucydidesRunner.class)
public class SearchScenarioSteps {
	
	AolLibrary aol;
	public SearchScenarioSteps() throws Exception{
		aol = new AolLibrary();
		}
	

	@Given("I am a shopper")
	public void ImShopper() {
		System.out.println("welcome");	
	}
	
	@When("I am viewing HomePage")
	public void viewHomePage() throws Exception{
		System.out.println("Viewing HomePage");
		aol.openURL("http://appliancesonline.com.au");
		aol.maximise();
	}
	
	@Then("I search for <product>")
	public void searchProduct(@Named("product") String product) throws Exception {
		try{
			System.out.println("looking for product " + product);
			aol.searchItem("Home_search_textbox",product, "Home_search_button");
			} catch (Exception e) {
				e.printStackTrace();
			}	
	}	
	
	
	@AfterStory
	public void afterStory(){
		aol.closeDriver();
	}
	

}
